<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="<?=base_url()?>/public/assets/layui/css/layui.css">
    <link rel="stylesheet" href="<?=base_url()?>/public/assets/mokui/css/admin.css">
    <link rel="stylesheet" href="<?=base_url()?>/public/assets/mokui/css/mokui.css">
    <title>后台管理</title>
</head>

<body class="login-body login-bg">
    <div class="login-wrapper">
        <form class="layui-form">
            
            <h2>用户登录</h2>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-username"></i>
                <input class="layui-input" name="username" placeholder="请输入登录账号" autocomplete="off" lay-vertype="tips" lay-verify="required" required="">
            </div>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-password"></i>
                <input class="layui-input" name="password" placeholder="请输入登录密码" type="password" lay-vertype="tips" lay-verify="required" required="">
            </div>
            <div class="layui-form-item layui-input-icon-group login-captcha-group">
                <i class="layui-icon layui-icon-auz"></i>
                <input class="layui-input" name="imgcode" placeholder="请输入验证码" autocomplete="off" lay-vertype="tips" lay-verify="required" required="">
                <?=ams_captcha(120, 40)?>
            </div>
            <div class="layui-form-item">
                <input type="checkbox" name="remember" title="记住密码" lay-skin="primary" checked="">
                <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary"><span>记住密码</span><i class="layui-icon layui-icon-ok"></i></div>
                <a href="javascript:;" class="layui-link pull-right">回首页</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" type="button" lay-filter="loginSubmit" lay-submit="">登录</button>
            </div>
            <div class="layui-form-item login-oauth-group text-center">
                <a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color:#3492ed;"></i></a>&emsp;
                <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat" style="color:#4daf29;"></i></a>&emsp;
                <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color:#CF1900;"></i></a>
            </div>
        </form>
    </div>
    <?=view('footer.html')?>
    <script>

        layui.use(['layer', 'form'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;

            

            /* 表单提交 */
            form.on('submit(loginSubmit)', function (data) {
                $.ajax({
                    type: 'POST',
                    url: '',
                    dataType: 'json',
                    data: data.field,
                    error: function (xhr, textStatus, error) {
                        layer.msg('服务器错误');
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1,
                                time: 1500
                            }, function () {
                                location.href = res.data.url;
                            });
                        } else {
                            layer.msg(res.msg, {
                                icon: 5,
                                anim: 6,
                                time: 2000
                            });
                        }

                    }
                });
                return false;
            });

            /* 图形验证码 */
            $('img.login-captcha').click(function () {
                this.src = this.src + '?t=' + (new Date).getTime();
            });

        });

    </script>
</body>

</html>
